package mutsumimod.cards.custom;

import com.megacrit.cardcrawl.actions.common.ReducePowerAction;
import com.megacrit.cardcrawl.cards.AbstractCard;
import com.megacrit.cardcrawl.characters.AbstractPlayer;
import com.megacrit.cardcrawl.monsters.AbstractMonster;
import mutsumimod.cards.BaseCard;
import mutsumimod.character.Mutsumi;
import mutsumimod.powers.LightBackPower;
import mutsumimod.powers.StandPower;
import mutsumimod.util.CardStats;

public class LightBack extends BaseCard {
    public static final String ID = makeID(LightBack.class.getSimpleName());
    public static final CardStats info = new CardStats(
            Mutsumi.Meta.CARD_COLOR,
            CardType.SKILL,
            CardRarity.UNCOMMON,
            CardTarget.SELF,
            0
    );

    public LightBack() {
        super(ID, info);
        setAttr(0,0,1);
        setAttrUpg(0,0,0);
    }

    @Override
    public void use(AbstractPlayer p, AbstractMonster m) {
        int amount=0;
        if(p.hasPower(StandPower.POWER_ID)){
            amount=p.getPower(StandPower.POWER_ID).amount;
        }
        if(amount>0){
            //不移除是为了触发power的onReduce的方法
            addToBot(new ReducePowerAction(p,p,StandPower.POWER_ID,amount));
            applyPowerSelf(new LightBackPower(p,amount),amount);
        }
    }

    @Override
    public AbstractCard makeCopy() { //Optional
        return new LightBack();
    }

    @Override
    public void updateDescription() {
        if(upgraded){
            this.rawDescription=cardStrings.UPGRADE_DESCRIPTION;
        }else{
            this.rawDescription=cardStrings.DESCRIPTION;
        }
        initializeDescription();
    }

    @Override
    public void upgrade() {
        if(!upgraded){
            upgradeName();
            updateDescription();
            selfRetain=true;
        }
    }


}
